package com.foreknow.eldclient.controller;

import com.foreknow.eldclient.po.Orders;
import com.foreknow.eldclient.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@ResponseBody
@RestController
@RequestMapping("OrdersController")
public class OrdersController {
    @Autowired
    OrdersService OS;
    @RequestMapping("/createOrders")
    public int createOrders(Orders orders) throws Exception{
        return OS.createOrders(orders);
    }

    @RequestMapping("/getOrdersById")
    public Orders getOrdersById(Integer orderId) throws Exception{
        return OS.getOrdersById(orderId);
    }

    @RequestMapping("/listOrdersByUserId")
    public List<Orders> listOrdersByUserId(String userId) throws Exception{
        return OS.listOrdersByUserId(userId);
    }

   @RequestMapping("/updateOrderState")
    public int updateOrderState(Integer orderId) throws Exception {
        return OS.updateOrderState(orderId);
    }

    @RequestMapping("/updateDeliState")
    public int updateDeliState(int orderId) {
        return OS.updateDeliState(orderId);
    }

    @RequestMapping("/listBusinessOrders")
    public List<Orders> listBusinessOrders(int businessId) {
        return OS.listBusinessOrders(businessId);
    }

}
